//
//  YWHttpTool.m
//  YWDaiGou
//
//  Created by Yeewii@hotmail.com on 16/6/13.
//  Copyright © 2016年 Yeewii@hotmail.com. All rights reserved.
//

#import "YWHttpTool.h"
#import "AFNetworking.h"


@implementation YWHttpTool
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ (void)GET:(NSString *)url params:(NSDictionary *)params success:(YWRequestSuccsee)success failure:(YWRequestFailure)failure;
{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"text/plain",@"application/json", nil];
    
    [manager GET:url parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        !success ? : success(responseObject);
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        !failure ? : failure(error);
    }];
}

+ (void)POST:(NSString *)url params:(NSDictionary *)params success:(YWRequestSuccsee)success failure:(YWRequestFailure)failure;
{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"text/plain", nil];
    [manager POST:url parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        !success ? : success(responseObject);
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        !failure ? : failure(error);
    }];
}

# pragma clang diagnostic pop
@end
